package com.example.task1.ui.AllService.PublicBenefit;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.PublicLogBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class PublicListAdapter extends BaseAdapter<PublicLogBean.RowsDTO> {


    private List<PublicLogBean.RowsDTO> data = new ArrayList<>();
    private Context context;
    private TextView tvTitle;
    private TextView tvAmount;
    private TextView tvName;
    private TextView tvTime;

    public PublicListAdapter(Context context) {
        this.context = context;
    }

    public void setData(List<PublicLogBean.RowsDTO> rows) {
        int i = data.size();
        data.addAll(rows);
        notifyItemInserted(i);
    }

    @Override
    protected int getLayout() {
        return R.layout.publiclist;
    }

    @Override
    protected Context getContext() {
        return context;
    }

    @Override
    protected List<PublicLogBean.RowsDTO> getData() {
        return data;
    }

    @Override
    protected void onBind(myHolder holder, PublicLogBean.RowsDTO date) {
        tvTitle.setText(date.getActivityName());
        tvAmount.setText("捐款金额：" + date.getDonateMoney());
        tvName.setText("捐款人：" + date.getUserName());
        tvTime.setText("----" + date.getCreateTime());
    }

    @Override
    protected void onBind(myHolder holder, PublicLogBean.RowsDTO date, int position) {
        super.onBind(holder, date, position);

    }

    @Override
    protected void holder(View itemView) {
        initView(itemView);
    }

    private void initView(View itemView) {
        tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
        tvAmount = (TextView) itemView.findViewById(R.id.tv_amount);
        tvName = (TextView) itemView.findViewById(R.id.tv_name);
        tvTime = (TextView) itemView.findViewById(R.id.tv_time);
    }
}
